﻿#region
using System.Collections.Generic;

#endregion

namespace MidnightPeach.EdmxTransformer
{
    public class Mapper
    {
        private readonly Dictionary<string, string> _dictionary = new Dictionary<string, string>();

        public void Add(string entityTo, string entityFrom, bool isPlural = false)
        {
            _dictionary.Add(entityTo + (isPlural ? "*" : ""), entityFrom);
        }

        public void Add(string entityTo, string propertyTo, string propertyFrom)
        {
            _dictionary.Add(entityTo + "." + propertyTo, propertyFrom);
        }

        public string this[string entityTo, bool isPlural = false]
        {
            get
            {
                string key = entityTo + (isPlural ? "*" : "");

                if (_dictionary.ContainsKey(key))
                    return _dictionary[key];

                return _dictionary[key];
            }
        }

        public string this[string entityTo, string propertyTo]
        {
            get
            {
                string key = entityTo + "." + propertyTo;

                if (_dictionary.ContainsKey(key))
                    return _dictionary[key];

                return propertyTo;
            }
        }
    }
}